package cn.ziroom.webservice;

import java.util.List;

import javax.jws.WebMethod;
import javax.jws.WebService;

import cn.ziroom.system.domain.Message;
import cn.ziroom.system.domain.User;
import cn.ziroom.system.service.MessageService;
import cn.ziroom.system.service.UserService;

/**
 * 系统对接HR用户接口类
 * 
 * @author Administrator
 * 
 */
@WebService(serviceName = "userInterface")
public class UserInterface {

	private UserService userService;

	private MessageService messageService; // 消息的服务器接口
	
	/**
	 * 同步用户接口访问数据
	 * 
	 * @param list
	 * @param operator
	 * @return
	 */
	@WebMethod
	public String synchroUser(List<User> list) {
		
		String ret = userService.synchroUser(list);
		
		Message msg = new Message();
		msg.setFunctionName("synchroCity");

		// 根据返回值来形成日志信息
		if (ret != null && ret.indexOf("_") > 0) {
			msg.setStatus(ret.substring(0, ret.indexOf("_")));
			msg.setJson(ret.substring(ret.indexOf("_") + 1));
		} else {
			msg.setStatus(ret);
		}

		messageService.insert(msg);
		
		return ret;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	public void setMessageService(MessageService messageService) {
		this.messageService = messageService;
	}
}
